import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },
  { path: '/', component: () => import('@/views/index/index'), hidden: true },
  { path: '/index', component: () => import('@/views/index/index'), hidden: true },
  {
    path: '/home',
    component: Layout,
    name: 'home',
    children: [
      {
        path: 'index',
        name: 'home',
        component: () => import('@/views/home/index'),
        meta: { title: '首页', icon: 'i-home' }
      }]
  },
  {
    path: '/authorize',
    component: () => import('@/views/authorize/index'),
    name: 'authorize',
    hidden: true
  },
  {
    path: '/authorize/fail',
    component: () => import('@/views/authorize/fail'),
    name: 'fail',
    hidden: true
  },
  {
    path: '/authorize',
    component: () => import('@/views/authorize/index'),
    name: 'authorize',
    children: [
      {
        path: 'auth',
        name: 'auth',
        component: () => import('@/views/authorize/index'),
        meta: { title: '添加公众号', icon: 'i-plus' }
      }]
  },
  {
    path: '/order',
    component: Layout,
    name: 'order',
    children: [
      {
        path: 'order',
        name: 'order',
        component: () => import('@/views/order/orderCreate'),
        meta: { title: '下单', icon: 'i-order' }
      }]
  },
  {
    path: '/orderlist',
    component: Layout,
    name: 'orderlist',
    children: [
      {
        path: 'orderlist',
        name: 'orderlist',
        component: () => import('@/views/order/index'),
        meta: { title: '订单管理', icon: 'i-list' }
      },
      {
        path: 'fanslist/:id',
        name: 'fanslist',
        hidden: true,
        component: () => import('@/views/order/fanslist'),
        meta: { title: '加粉明细' }
      }]
  },
  {
    path: '/wxinfo',
    component: Layout,
    name: 'wxinfo',
    children: [
      {
        path: 'wxinfo',
        name: 'wxinfo',
        component: () => import('@/views/wxinfo/index'),
        meta: { title: '公众号信息', icon: 'i-wxinfo' }
      }]
  },
  {
    path: '/data',
    component: Layout,
    name: 'data',
    meta: {
      title: '数据中心',
      icon: 'i-data'
    },
    children: [
      {
        path: 'fans',
        name: 'fans',
        show: true,
        component: () => import('@/views/statistics/index'),
        meta: { title: '粉丝统计', icon: 'i-point' }
      }
    ]
  },
  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history',
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

